package com.yushu.authority.mapper;


import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yushu.authority.pojo.bo.PmMenu;
import com.yushu.authority.pojo.bo.PmRole;
import com.yushu.authority.pojo.vo.PmRoleVO;
import com.yushu.authority.pojo.vo.PmUserVO;
import com.yushu.common.util.pager.Pages;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;


/**
 * 
 * @author test
 * @CreateDate 2020-12-03 15:47:24
 */
public interface PmRoleMapper extends BaseMapper<PmRole> {

 List<PmRoleVO> selectPageList(Pages page, @Param("ew") EntityWrapper<PmRoleVO> wrapper);

    /**
     * <pre>通过用户查询角色*
     * </pre>
     *
     * @param
     * @return
     *  @author itcat
     * @CreateDate 2020-10-20 16:42:56
     */
    List<PmRole> selectRolesByUserId(@Param("userId") String userId);


    /**
     * 2019-6-21 19:50:35
     * 批量删除角色用户关联表
     *
     * @param roleUserQueryList
     */
    void batchDeleteRoleOnUsers(@Param("list") List<Map<String, Object>> roleUserQueryList);

    /**
     * 2019-6-21 19:50:45
     * 批量插入角色用户关联表
     *
     * @param roleUserQueryList
     */
    void insertRoleUser(@Param("list") List<Map<String, Object>> roleUserQueryList);


    /**
     * <pre>查询当前角色下的菜单
     * </pre>
     *
     * @param
     * @return
     *  @author itcat
 	* @CreateDate 2020-10-20 16:42:56
     */
    List<PmMenu> selectMenuByRole(@Param("id") String roleID);

    //通过角色ID查询  是否绑定用户
    int selectUserByRoleId(@Param("id") String roleID);

    List<PmRole> queryRolesOnUsers(@Param("users") List<PmUserVO> users);

    List<PmRole> selectRoleByUser(@Param("user") PmUserVO pmUser) throws Exception;

    //批量插入角色菜单权限表 2019/7/26 11:29
    void batchInsertMenuOnRole(@Param("list") List<Map<String, String>> menuOnRoleMaps);

    //批量删除角色菜单权限表 2019/7/26 11:29
    void batchDeleteMenuOnRole(@Param("list") List<Map<String, String>> menuOnRoleMaps);

    //批量插入搜索框角色关联表 2019-8-7 10:33:27
    void batchInsertSearchOnRole(@Param("list") List<Map<String, String>> searchOnRoleMaps);

    //批量删除搜索框角色关联表 2019-8-7 10:33:30
    void batchDeleteSearchOnRole(@Param("list") List<Map<String, String>> searchOnRoleMaps);

    //批量删除用户角色关联表 2019-11-8 12:37:15
//    void batchDeleteRoleOnUsers(List<String> ids);

    PmRoleVO queryRoleByKey(@Param("id") String id);

    int queryCountByName(@Param("map") Map map);

    int selectMenusByRoleId(@Param("id") String ids);
//查询用户下是否存有角色
    int queryUserCountOnRole(@Param("list")List<PmRole> pmRoles);
    
     boolean saveRole(PmRole pmRole);
}
